package com.xinan.system.meetwx;

import java.util.List;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

@TableBind(tableName = "tb_meet_regist")
public class TbMeetRegist extends Model<TbMeetRegist> {

	private static final long serialVersionUID = 1L;

	public static final TbMeetRegist dao = new TbMeetRegist();

	// columns START
	private String ID = "id"; // 主键
	private String TRANSMITID = "transmitid"; // 转发ID
	private String REGISTUSERID = "registuserid"; // 报名人ID
	private String TRANSMITUSERID = "transmituserid"; // 转发人ID
	private String MEETID = "meetid"; // 会议ID
	private String BUSINESSID = "businessid"; // 报名的业务ID：软文ID或者课程ID
	private String TYPE = "type"; // 业务类型：1 软文 2 课程
	private String REGISTTIME = "registtime"; // 报名时间
	private String STATUS = "status"; // 状态
	private String FINISH = "finish"; // 是否处理完成
	private String REMARK = "remark"; // 备注
	private String CREATETIME = "createtime"; // 创建时间
	private String CREATEID = "createid"; // 创建者

	public void setId(int value) {
		set(ID, value);
	}

	public int getId() {
		return get(ID);
	}

	public void setTransmitid(int value) {
		set(TRANSMITID, value);
	}

	public int getTransmitid() {
		return get(TRANSMITID);
	}

	public void setRegistuserid(int value) {
		set(REGISTUSERID, value);
	}

	public int getRegistuserid() {
		return get(REGISTUSERID);
	}

	public void setTransmituserid(int value) {
		set(TRANSMITUSERID, value);
	}

	public int getTransmituserid() {
		return get(TRANSMITUSERID);
	}

	public void setMeetid(int value) {
		set(MEETID, value);
	}

	public int getMeetid() {
		return get(MEETID);
	}

	public void setBusinessid(int value) {
		set(BUSINESSID, value);
	}

	public int getBusinessid() {
		return get(BUSINESSID);
	}

	public void setType(int value) {
		set(TYPE, value);
	}

	public int getType() {
		return get(TYPE);
	}

	public void setRegisttime(String value) {
		set(REGISTTIME, value);
	}

	public String getRegisttime() {
		return get(REGISTTIME);
	}

	public void setStatus(int value) {
		set(STATUS, value);
	}

	public int getStatus() {
		return get(STATUS);
	}

	public void setFinish(int value) {
		set(FINISH, value);
	}

	public int getFinish() {
		return get(FINISH);
	}

	public void setRemark(String value) {
		set(REMARK, value);
	}

	public String getRemark() {
		return get(REMARK);
	}

	public void setCreatetime(String value) {
		set(CREATETIME, value);
	}

	public String getCreatetime() {
		return get(CREATETIME);
	}

	public void setCreateid(String value) {
		set(CREATEID, value);
	}

	public String getCreateid() {
		return get(CREATEID);
	}

	// columns END

	public List<TbMeetRegist> findAll() {
		return find("select * from tb_meet_regist");
	}

	/**
	 * @param where
	 * @return Record
	 */
	public List<Record> findAlls(String where) {
		String sqlExp = " from tb_meet_regist";
		if (StrKit.notBlank(where)) {
			sqlExp += " where " + where;
		}
		return Db.find("select * " + sqlExp);

	}

	public Page<TbMeetRegist> page(int pageNumber, int pageSize, String where) {
		String sqlExp = "from tb_meet_regist";
		if (StrKit.notBlank(where)) {
			sqlExp += " where " + where;
		}
		return paginate(pageNumber, pageSize, "select *", sqlExp);
	}

	/**
	 * 客服页面
	 * 
	 * @date 2015年4月10日 下午2:38:41
	 * @author FLY的狐狸 369191470@qq.com
	 * @param pageNumber
	 * @param pageSize
	 * @param where
	 * @return
	 */
	public Page<TbMeetRegist> querybykf(int pageNumber, int pageSize, String where) {
		String sqlExp = " from ( select t.id,t.registuserid "
				+ " ,t.meetid,m.title,u.realname,u.telphone,u.cardno,t.registtime,t.status,t.remark " // 展示列
				+ " from tb_meet_regist t " //
				+ " LEFT JOIN wx_user u on t.registuserid = u.id " //
				+ " LEFT JOIN tb_meet m on t.meetid = m.id ) a";
		if (StrKit.notBlank(where)) {
			sqlExp += " where " + where;
		}
		return paginate(pageNumber, pageSize, "select *", sqlExp);
	}
}
